package xcu.lxj.nettychat.chat.domain.vo.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * @Author XinJian Lei
 * @Date 2024/9/21 15:52
 * @Version 1.0
 */

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Schema(name = "聊天消息响应体")
public class ChatMsgResp implements Serializable {

    /**
     * 发送者信息
     */
    @Schema(description = "发送者信息")
    private UserInfo fromUser;

    /**
     * 消息
     */
    @Schema(description = "消息")
    private Message message;

    /**
     * 发送者信息
     */
    @Data
    @Schema(name = "发送者信息")
    public static class UserInfo implements Serializable {
        @Schema(description = "uid")
        private Long uid;
    }

    /**
     * 消息内容
     */
    @Data
    @Schema(name = "消息内容")
    public static class Message implements Serializable {
        @Schema(description = " 消息 id")
        // 消息 id
        private Long id;

        // 房间号
        @Schema(description = "房间号")
        private Long roomId;

        // 发送时间
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @Schema(description = "发送时间")
        private Date sendTime;

        /**
         * 消息类型
         * @see xcu.lxj.nettychat.chat.domain.enums.MessageTypeEnum
         */
        @Schema(description = "消息类型")
        private Integer type;

        /**
         * 消息主体 根据类型 获得消息体
         * @see TextMsgResp
         * @see xcu.lxj.nettychat.chat.domain.entity.msg
         */
        @Schema(description = "消息主体 根据类型 获得消息体")
        private Object body;
    }
}
